import router from "./index";
import { getAll,getMenu } from "@/api/systemManage/menuManage";

export function listss () {
    let routerLisr = []
    getMenu().then((res) => {
        routerLisr.push({
            path: '/whitee',
            name: 'whitee',
            component: () => import('@/view/whitee.vue'),
            meta: {
                title: 'whitee'
            },
        })
        res.data.forEach(item => {
            if (item.component) {
                const temp = {
                    path: item.path,
                    name: item.name,
                    // component: () => import(`@/${item.component}`),
                    meta: {
                        title: item.nameZh
                    },
                }
                temp.component = () => import(`@/${item.component}`)
                routerLisr.push(temp)
            }
            if (item.children.length > 0) {
                item.children.forEach(i => {
                    if (i.children.length > 0) {
                        i.children.forEach(j => {
                            if (j.component) {
                                const temp3 = {
                                    path: j.path,
                                    name: j.name,
                                    // component: () => import(`@/${j.component}`),
                                    meta: {
                                        title: j.nameZh
                                    },
                                }
                                temp3.component = () => import(`@/${j.component}`)
                                routerLisr.push(temp3)
                            }

                        })
                    }
                    else {
                        // 组装路由配置
                        if (i.component) {
                            const temp2 = {
                                path: i.path,
                                name: i.name,
                                //component: () => import(`@/${i.component}`),
                                meta: {
                                    title: i.nameZh
                                },
                            }
                            temp2.component = () => import(`@/${i.component}`)
                            routerLisr.push(temp2)
                        }

                    }

                })

            }
        })
        let rou = {
            path: "/",
            component: () => import("../components/common/Base.vue"),
            meta: {
                title: "公共部分",
            },
            children: routerLisr
        }
        router.addRoute(rou)
    })


}